
<template>
  <div v-show="customData.visible" class="storeitemEdit">
    <el-dialog
      id="dialogBox"
      title="编辑门店商品"
      width="25%"
      :visible.sync="customData.visible"
      @close="hide"
    >
      <div class="boxMarginBottom">
        <el-row :gutter="20">
          <el-col :span="6" class="inputName">商品库存：</el-col>
          <el-col :span="14">
            <quantity-value
              :style-value="'width: 200px'"
              :quantity="editData.itemStock || 0"
              placeholder=""
              :disabled="editFlag"
              @handleQuantityChange="$set(editData, 'itemStock', $event)"
            />
          </el-col>
        </el-row>
      </div>
      <div class="boxMarginBottom">
        <el-row :gutter="20">
          <el-col :span="6" class="inputName">商品价格：</el-col>
          <el-col :span="14">
            <amount-input
              :style-value="'width: 200px'"
              :amount="String(editData.itemPrice || '')"
              :placeholder="'金额（元）'"
              :disabled="editFlag"
              @handleAmountChange="$set(editData, 'itemPrice', $event)"
            />
          </el-col>
        </el-row>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="hide">取 消</el-button>
        <el-button type="primary" @click="submit()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import $ from 'jquery'
import _validate from '../../../../../framework/commonJs/wptx_validate'
import _tools from '../../../../../framework/commonJs/wptx_tools'
import _common from '../../../../../framework/commonJs/wptx_common'
import _api from '../../../../../framework/API/storeItem'
import _allApi from '../../../../../framework/API/apiAll'
import _channelitemsynctaskApi from '../../../../../framework/API/channelitemsynctask'
import AmountInput from '../../../../../components/TestAndVerify/amount.vue'
import QuantityValue from '../../../../../components/TestAndVerify/QuantityValue.vue'
const _FUNCTION_NAME = ''
export default {
  components: { AmountInput, QuantityValue },
  filters: {},
  data() {
    return {
      editFlag: false,
      editData: {
        itemPrice: '',
        itemStock: '',
        storeItemId: ''
      },
      searchData: {

      },
      searchDataBuffer: {

      },
      customData: {
        visible: false
      },
      form: {}
    }
  },
  computed: {},
  created() { },
  mounted() {
  },
  beforeDestroy() { },
  methods: {
    show(data) {
      const self = this
      self.customData.visible = true
      self.editData.storeItemId = data.id
      self.editData.itemPrice = data.itemPrice
      self.editData.itemStock = data.itemStock
    },
    hide() {
      const self = this
      self.customData.visible = false
    },
    submit() {
      const self = this
      _api.editStoreItem(self, self.editData, self.callBack_Increase)
    },
    callBack_Increase(data) {
      const self = this
      if (_validate.checkEmpty(data)) {
        _validate.openTip(self, '获取超时，请稍后重试', 'warning')
      } else {
        _validate.openTip(self, '保存成功', 'success')
        this.hide()
        this.$parent.onInit()
      }
    }

  }
}
</script>
<style>
.newTwo {
  padding-bottom: 60px;
}
.add-right {
  float: right;
}
.boxMarginBottom {
  margin-bottom: 20px;
}
.el-upload--picture-card > div {
  width: 146px;
  height: 146px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.el-upload--picture-card > div img {
  max-width: 100%;
  max-height: 100%;
}
.contion-header {
  display: inline-block;
  box-sizing: border-box;
}
.text-r {
  text-align: right;
}
.tree-div {
  position: absolute;
  height: auto;

  z-index: 10;
  overflow-y: scroll;
  width: 58%;
  background: #eee;
}
.tree {
  max-height: 200px;

  background: #eee;
}
.el-card {
  overflow: visible;
}
</style>
